package com.xuecheng.content.convert;


import com.xuecheng.api.content.model.dto.TeachplanDTO;
import com.xuecheng.api.content.model.vo.TeachPlanVO;
import com.xuecheng.content.entity.Teachplan;
import com.xuecheng.content.entity.ext.TeachplanNode;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface TeachPlanConvert {
    TeachPlanConvert INSTANCE = Mappers.getMapper(TeachPlanConvert.class);

    /**
     * po-->dto
     *
     * @param teachplanNode
     * @return
     */
    @Mappings(
            {@Mapping(source = "id", target = "teachPlanid"),
                    @Mapping(source = "childrenNodes", target = "teachPlanTreeNodes")}
    )
    TeachplanDTO node2dto(TeachplanNode teachplanNode);


    List<TeachplanDTO> nodes2dto(List<TeachplanNode> nodes);

    @Mapping(source = "teachPlanid", target = "id")
    Teachplan dto2entity(TeachplanDTO dto);

    @Mapping(source = "id", target = "teachPlanid")
    TeachplanDTO entity2dto(Teachplan teachplan);

    @Mapping(source = "teachPlanId",target = "teachPlanid")
    TeachplanDTO vo2dto(TeachPlanVO vo);

}
